#pragma once

#include <cassert>
#include <queue>
#include <array>
#include <bitset>
#include <vector>

#include "njm_entity.hpp"
#include "njm_component.hpp"

namespace njm
{
    class EntityManager
    {
    public:
        EntityManager();
        ~EntityManager();
        void Init();
        void Clear();

        Entity CreateEntity();
        void DestroyEntity(Entity entity);

        void SetSignature(Entity entity, Signature signature);
        Signature GetSignature(Entity entity);

        bool HasSignature(Entity entity, Signature signature);
        bool HasAnySignature(Entity entity, Signature signature);
        std::vector<Entity> GetEntitiesWithSignature(Signature signature);

    private:
        std::queue<Entity> availableEntities{};
        std::array<Signature, maxEntities> entitySignatures{};
        uint32_t currentLivingEntityCount = 0;
    };
}
